package com.qf.j2112.service.impl;

import com.github.pagehelper.PageHelper;
import com.qf.j2112.mapper.SysUserMapper;
import com.qf.j2112.po.SysUser;
import com.qf.j2112.service.SysUserService;
import com.qf.j2112.utils.PageUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SysUserServiceImpl implements SysUserService {

    @Resource
    private SysUserMapper sysUserMapper;

    @Override
    public SysUser findUserByUname(String uname) {
        return sysUserMapper.findUserByUname(uname);
    }

    @Override
    public List<SysUser> findAllSysUser(PageUtil pageUtil) {
        PageHelper.startPage(pageUtil.getPage(),pageUtil.getPageSize());
        return sysUserMapper.findAll();
    }

    @Override
    public SysUser findUserByUid(int uid) {
        return  sysUserMapper.findUserByUid(uid);
    }

    @Override
    public SysUser addSysUser(SysUser user) {
        sysUserMapper.addSysUser(user);
        return user;
    }

    @Override
    public boolean updateSysUser(SysUser user) {
        int i=sysUserMapper.updateSysUser(user);
        if(i>-1){
            return true;
        }
        return false;
    }

    @Override
    public boolean deleteSysUser(int uid) {
        int i=sysUserMapper.deleteSysUser(uid);
        if(i>-1){
            return true;
        }
        return false;
    }

    @Override
    public int countUser() {
        return sysUserMapper.countUser();
    }
}
